package Annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

public class AnnotationDemo2 {


    public static void main(String[] args) throws Exception {
        BookStore bookStore = new BookStore();
        test(bookStore);
    }




    public static  void test(Object obj) throws Exception {
        //得到类对象
        Class c=obj.getClass();
        Method m =c.getDeclaredMethod("test");
        //判断这个类上是否有这个注解
        if (c.isAnnotationPresent(Book.class)){
            //获取该注解对象
            Book book=(Book)c.getDeclaredAnnotation(Book.class);
            System.out.println(book.value());
            System.out.println(book.price());
            System.out.println(Arrays.toString(book.authors()));
        }
    }

}
